package cn.iocoder.yudao.module.form.controller;

import cn.iocoder.yudao.framework.common.pojo.CommonResult;
import cn.iocoder.yudao.module.form.dataobject.FormTotalChart;
import cn.iocoder.yudao.module.form.service.IFormTotalChartService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;

/**
 * 图总类别Controller
 *
 * @author Fan KaiXiang
 * @date 2022-08-30
 */
@Api(tags = "a图表展示总类别")
@RestController
@RequestMapping("/admin-api/form/totalchart")
public class FormTotalChartController
{
    @Autowired
    private IFormTotalChartService formTotalChartService;

    /**
     * 查询图总类别列表
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:list')")
    @GetMapping("/list")
    @ApiOperation(value = "获取图表总类别列表", notes = "获取图表总类别列表")
    public CommonResult<List<FormTotalChart>> list(FormTotalChart formTotalChart)
    {
//        startPage();
        List<FormTotalChart> list = formTotalChartService.selectFormTotalChartList(formTotalChart);
        return success(list);
    }

    /**
     * 查询图总的类别
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:list')")
    @GetMapping("/getType")
    @ApiOperation(value = "获取图表的类别", notes = "获取图表的类别")
    public CommonResult<List<String>> getType()
    {
//        startPage();
        List<String> list = formTotalChartService.selectFormType();
        return success(list);
    }

    /**
     * 导出图总类别列表
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:export')")
//    @Log(title = "图总类别", businessType = BusinessType.EXPORT)
//    @PostMapping("/export")
//    public void export(HttpServletResponse response, FormTotalChart formTotalChart)
//    {
//        List<FormTotalChart> list = formTotalChartService.selectFormTotalChartList(formTotalChart);
//        ExcelUtil<FormTotalChart> util = new ExcelUtil<FormTotalChart>(FormTotalChart.class);
//        util.exportExcel(response, list, "图总类别数据");
//    }

    /**
     * 获取图总类别详细信息
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:query')")
    @GetMapping(value = "/{chartId}")
    @ApiOperation(value = "根据id获取图表总类别", notes = "根据id获取图表总类别列表")
    public CommonResult<FormTotalChart> getInfo(@PathVariable("chartId") Long chartId)
    {
        return success(formTotalChartService.selectFormTotalChartByChartId(chartId));
    }

    /**
     * 新增图总类别
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:add')")
    @ApiOperation(value = "新增图表总类别", notes = "新增图表总类别")
    @PostMapping
    public CommonResult<Integer> add(@RequestBody FormTotalChart formTotalChart)
    {
        return success(formTotalChartService.insertFormTotalChart(formTotalChart));
    }

    /**
     * 修改图总类别
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:edit')")
    @ApiOperation(value = "修改图表总类别", notes = "修改图表总类别")
    @PutMapping
    public CommonResult<Integer> edit(@RequestBody FormTotalChart formTotalChart)
    {
        return success(formTotalChartService.updateFormTotalChart(formTotalChart));
    }

    /**
     * 删除图总类别
     */
//    @PreAuthorize("@ss.hasPermi('form:chart:remove')")
    @ApiOperation(value = "删除图表总类别", notes = "删除图表总类别")
	@DeleteMapping("/{chartIds}")
    public CommonResult<Integer> remove(@PathVariable Long[] chartIds)
    {
        return success(formTotalChartService.deleteFormTotalChartByChartIds(chartIds));
    }
}
